#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

int main()
{
	int num = 0;
	int i = 0;
	int j = 0;
	for (num = 1; num < 100000; num++)
	{
		int ret = 0;
		int count = 0;
		int a = num;
		int b = num;
		for (i = 0; a > 0; i++)
		{
			count++;
			a /= 10;
		}

		for (j = 0; j < count; j++)
		{
			int d = 1;
			int c = 0;
			c = b % 10;
			for (i = 0; i < count; i++)
			{
				d *= c;
			}
			ret += d;
			b /= 10;
		}
		if (ret == num)
		{
			printf("%d ", num);
		}
	}
	return 0;
}